﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;

namespace Tracer
{
    /// <summary>
    /// An instance which will be serialized by GT, sent to a client repeater, and echoed to all clients.
    /// Contains the location of a certain color of pointer.
    /// Notes:
    ///     -   If you intend to send something using GT, ensure it is Serializable!
    ///     -   Lots of classes are *not* serializable, therefore, you must convert them into a simpler form.
    ///         -   Ex: I once used a matrix class; in order to send it via GT, I had to convert it to an array of doubles.
    /// </summary>
    [Serializable]
    public class PositionUpdateMessage
    {
        /// <summary>
        /// Why am I using byte instead of just using a color? Because Microsoft didn't set put a Serializable tag on the
        /// Color class.
        /// </summary>
        private byte R;
        private byte B;
        private byte G;

        /// <summary>
        /// Creates the message, converting the unserializable field into a serializable form.
        /// </summary>
        public PositionUpdateMessage(Color pointerColor, System.Windows.Point location)
        {
            R = pointerColor.R;
            B = pointerColor.B;
            G = pointerColor.G;
            this.location = location;
        }

        #region Irrelevant Fields
        private Point location;
        #endregion

        #region Get/Set
        public Color PointerColor
        {
            get 
            {
                Color c = new Color();
                c.R = R;
                c.B = B;
                c.G = G;
                c.A = 255;
                return c;
            }
        }

        public Point Location
        {
            get { return location; }
        }
        #endregion
    }
}
